define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, $timeout, GoDialog,Pay_password,GoPage,Auth,$stateParams) {
		$scope.scope = new Object();
		$scope.info = Auth.get_loginInfo();
		$scope.order_id = $stateParams.order_id;
		
		//清空输入
		$scope.clearInput = function(type){
			if(type==1) $scope.scope.login_password = "";
			if(type==2) $scope.scope.pay_password = "";
			if(type==3) $scope.scope.confrim_password = "";
		}
		
		
		//修改支付密码
		$scope.change_password = function() {
			if(!$scope.scope.login_password) {
				GoDialog.toast("请输入登录密码！");
				return;
			}
			if(!$scope.scope.pay_password) {
				GoDialog.toast("请输入支付密码！");
				return;
			}
			if(!$scope.scope.confrim_password) {
				GoDialog.toast("请再次输入支付密码！");
				return;
			}
			Pay_password.change_password($scope.scope.login_password,$scope.scope.pay_password, $scope.scope.confrim_password, function(data) {
				$scope.success = data;
				if(data.success == true) {
					GoDialog.toast("支付密码设置成功");
					if($scope.order_id){
						GoPage.go_states("afpay", { "order_id": $scope.order_id });
					}else{
						GoPage.go_states("t-set");//修改完后跳转到t-set页面
					}
				} else{
					GoDialog.alert("提示",data.msg);
				}
			});
		};
		
		
	}

	controller.$inject = ['$scope', '$timeout', 'GoDialog','Pay_password','GoPage','Auth','$stateParams'];

	return app.registerController("pay_passwordctrl",controller);
});